﻿using System;
using System.Collections.Generic;
using IOCDemo.Domain;
using IOCDemo.Interfaces;

namespace IOCDemo.Services
{
    public class BankingService : IBankingService
    {
        private readonly IAccountService accountService;
        private readonly IUserService userService;

        public BankingService(IAccountService accountService, IUserService userService)
        {
            this.accountService = accountService;
            this.userService = userService;
        }

        #region Implementation of IAccountService

        public IList<Account> GetAccounts(AuthToken authToken)
        {
            return accountService.GetAccounts(authToken);
        }

        public IList<Transaction> GetTransactions(AuthToken authToken, TimeSpan searchWindow, int page, int pageSize)
        {
            return accountService.GetTransactions(authToken, searchWindow, page, pageSize);
        }

        public void Transfer(AuthToken authToken, Transaction transaction)
        {
            accountService.Transfer(authToken, transaction);
        }

        #endregion

        #region Implementation of IUserService

        public AuthToken AuthenticateUser(string username, string password)
        {
            return userService.AuthenticateUser(username, password);
        }

        public User GetUser(AuthToken authToken)
        {
            return userService.GetUser(authToken);
        }

        #endregion
    }
}